﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LowLevelGraphics.Extensions
{
    /// <summary>
    /// 
    /// </summary>
    public static class IEnumerableExtensions
    {
        /// <summary>
        /// Toes the specified _n start.
        /// </summary>
        /// <param name="_nStart">The _n start.</param>
        /// <param name="_nEnd">The _n end.</param>
        /// <returns></returns>
        public static IEnumerable<int> To(this int _nStart, int _nEnd)
        {
            var diff = _nEnd - _nStart > 0 ? 1 : -1;
            for (var current = _nStart; current != _nEnd; current += diff)
            {
                yield return current;
            }
        }

        /// <summary>
        /// Toes the specified _CH start.
        /// </summary>
        /// <param name="_chStart">The _CH start.</param>
        /// <param name="_chEnd">The _CH end.</param>
        /// <returns></returns>
        public static IEnumerable<char> To(this char _chStart, char _chEnd)
        {
            var start = (int)_chStart;
            var end = (int)_chEnd;
            var diff = end - start > 0 ? 1 : -1;
            for (var current = start; current != end; current += diff)
            {
                yield return (char)current;
            }
        }
    }
}
